home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / Winter Shell 1.0d2 / Source / PopupCDEF 1.0b2 / PopupLib.h < prev   
Encoding:
C/C++ Source or Header  |  1994-01-08  |  5.6 KB  |  159 lines  |  [TEXT/KAHL]

  1. /*
  2.     Distribution
  3.     ------------
  4.     
  5.     You can use this code and the compiled popup CDEF in any freely
  6.     distributed product (as in the GNU General Public License), just
  7.     give credit somewhere appropriate (like the documentation). For
  8.     commercial distribution please contact the author. Please keep the
  9.     files together if you redistribute them.
  10.     
  11.     I would also be interested in any improvements made to
  12.     this software.
  13.     
  14.     (c) Copyright 1994, Ari Halberstadt
  15.     
  16.     Ari Halberstadt
  17.     9 Whittemore Rd.
  18.     Newton, MA 02158-2105
  19.     USA
  20.     
  21.     ari@world.std.com
  22. */
  23.     
  24. #pragma once
  25.  
  26. /* Version of this library. Useful for compatability between older versions
  27.     of the CDEF and using a newer version of the popup library to manipulate
  28.     the CDEF popups from within a program. The program must first check the
  29.     popup's version before calling any popup library routines. */
  30. #define kPopupVersion    (0)
  31.  
  32. /* Part code returned when the mouse is in a popup menu. */
  33. #define kPopupPartCode    (1)
  34.  
  35. /*    The control variation code popupTypeIn is used by the popup CDEF.
  36.     With this variation code, only the popup's down arrow is drawn,
  37.     the popup's title and current selection are not drawn. Type-in
  38.     popup menus are described in IM-VI, p2-37. */
  39. #define popupTypeIn        (2)
  40.  
  41. #ifndef arrowCursor
  42.     /* arrowCursor is defined in DrawLib.h,
  43.         which also defines TextState */
  44.     typedef struct {
  45.         short    font;
  46.         Style    face;
  47.         short    mode;
  48.         short    size;
  49.     } TextState;
  50. #endif /* arrowCursor */
  51.  
  52. /* Drawing environment data which must be remembered before any drawing
  53.     of the popup menu is begun and restored after all drawing has finished. */
  54. typedef struct {
  55.     GrafPtr        port;
  56.     PenState        pen;
  57.     TextState    text;
  58.     RgnHandle    clip;
  59. } PopupEnvType;
  60.  
  61. /* rectangles defining the various areas of a popup menu */
  62. typedef struct {
  63.     Rect maxbounds;    /* maximum bounding rectangle of popup */
  64.     Rect bounds;        /* rectangle around all of popup */
  65.     Rect hilite;        /* hilited when a selection is being made */
  66.     Rect title;            /* contains the popup's title */
  67.     Rect selection;    /* contains the currently selected item */
  68.     Rect arrow;            /* contains the down arrow */
  69. } PopupRectanglesType;
  70.  
  71. /* This is the same structure as the popupPrivateData record described
  72.     in IM-VI, p3-19. By making this the first element in the popup
  73.     structure, a CDEF based on this popup library is made more
  74.     compatible with Apple's CDEF. */
  75. typedef struct {
  76.     MenuHandle    mHandle;
  77.     short            mID;
  78. } PopupPrivateType, *PopupPrivatePtr, **PopupPrivateHandle;
  79.  
  80. /* structure containing all the data needed by the popup menu */
  81. typedef struct {
  82.  
  83.     /* these first two fields will never be changed, other fields may change */
  84.     PopupPrivateType private;    /* for compatability with Apple's CDEF */
  85.     short                version;        /* version of the code that created this popup menu */
  86.  
  87.     /* fields specified on creation of the popup menu (maxbounds is in
  88.         rectangles field) */
  89.     GrafPtr            port;            /* port to draw into */
  90.     MenuHandle        menu;            /* handle to menu */
  91.     
  92.     /* offscreen bitmap handles */
  93.     RgnHandle        utilRgn;        /* utility region */
  94.     Handle            baseAddr;    /* bitmap's base address */
  95.     
  96.     /* internal state information */
  97.     PopupRectanglesType r;        /* rectangles enclosing areas of the popup menu */
  98.     struct {
  99.         PopupEnvType oldenv;     /* old drawing environment */
  100.         MenuHandle    selection;    /* menu containing the currently selected item */
  101.         short            current;        /* currently selected item number */
  102.         Boolean        envset:1;    /* true after drawing environment has been setup */
  103.         Boolean        gotmenu:1;    /* used by CDEF; true means CDEF created menu */
  104.     } state;
  105.     
  106.     /* User settable attributes of the menu. External functions
  107.         are provided to manipulate these fields. */
  108.     struct {
  109.         void            *data;        /* pointer to application defined data */
  110.         Boolean        draw:1;        /* false disables drawing and calculating */
  111.         Boolean        visible:1;    /* true means popup is visible */
  112.         Boolean        enabled:1;    /* true if menu is enabled */
  113.         Boolean        typein:1;    /* true shows only arrow, like a type-in menu */
  114.         Boolean        wfont:1;        /* true uses window font, not system font */
  115.         char            mark;            /* character used to mark current item */
  116.         char            just;            /* text justification */
  117.         struct {
  118.             Style        style;        /* style of popup's title */
  119.             short        width;        /* width of title; 0 if resized dynamically */
  120.             Handle    str;            /* popup's title string */
  121.         } title;
  122.     } attr;
  123. } PopupType, *PopupPtr, **PopupHandle;
  124.  
  125. Boolean PopupValid(PopupHandle popup);
  126.  
  127. void PopupCalculate(PopupHandle popup);
  128. void PopupDraw(PopupHandle popup);
  129. void PopupHilite(PopupHandle popup);
  130. void PopupSelect(PopupHandle popup);
  131. Boolean PopupWithin(PopupHandle popup, Point pt);
  132.  
  133. short PopupVersion(PopupHandle popup);
  134. short PopupCurrent(PopupHandle popup);
  135. void PopupCurrentSet(PopupHandle popup, short current);
  136. void PopupDrawSet(PopupHandle popup, Boolean draw);
  137. void PopupVisibleSet(PopupHandle popup, Boolean visible);
  138. void PopupMarkSet(PopupHandle popup, char mark);
  139. void PopupEnableSet(PopupHandle popup, Boolean enabled);
  140. void PopupTypeInSet(PopupHandle popup, Boolean typein);
  141. void PopupBounds(PopupHandle popup, Rect *bounds);
  142. void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
  143. void PopupTitle(PopupHandle popup, Str255 title);
  144. void PopupTitleSet(PopupHandle popup, const Str255 title);
  145. void PopupTitleWidthSet(PopupHandle popup, short width);
  146. void PopupTitleStyleSet(PopupHandle popup, Style style);
  147. void PopupUseWFontSet(PopupHandle popup, Boolean wfont);
  148. void PopupJustSet(PopupHandle popup, short just);
  149.  
  150. PopupHandle PopupBegin(GrafPtr port, MenuHandle menu, const Rect *bounds);
  151. void PopupEnd(PopupHandle popup);
  152.  
  153. pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
  154. void PopupCDEFAttach(ControlHandle ctl);
  155. void PopupCDEFDetach(ControlHandle ctl);
  156.  
  157. const /* EventTableType */ void *PopupEventTable(void);
  158. void PopupEventTableRegister(void);
  159.